"use strict";
/**
 * @name data
 * 玩家数据
 */

/**
 * @name role
 * 基本信息
 */
exports.role = function () {
    let role = this.model.mongo('role', this.sid, this.uid);
    //哎呀要对role里的编队做一个特殊处理呀

    return role.get().then((data) => {
        // 删除idCard 和realName
        delete data.idCard;
        delete data.realName;
        delete data.useTalentItem;
        return data;
    });
};

/**
 * @name item
 * @param int bag 背包ID，留空获取所有
 * 道具列表(不推荐)
 */
exports.item = function () {
    let bag = this.get("bag", "int");
    let model = this.model.mongo("item", this.sid, this.uid);
    return model.mget(bag);
}

/**
 * @name itemCount
 * @param int bag 背包ID的物品数量
 * 道具数量(不推荐)
 */
exports.itemCount = function () {
    let bag = this.get("bag", "int");
    let model = this.model.mongo("item", this.sid, this.uid);
    return model.mcount(bag);
}


/**
 * @name itemPage
 * @param int bag 背包ID，留空获取所有
 * @param int page 页码
 * 道具列表-分页
 * @tip 每页500个，页码从1开始
 */
exports.itemPage = function () {
    let bag = this.get("bag", "int");
    let page = this.get("page", "int");
    let model = this.model.mongo("item", this.sid, this.uid);
    return model.mpage(page, bag);
}

/**
 * @name daily
 * 日常数据
 */

exports.daily = function () {
    let days = this.config('base', 'dataMaxDay').val || 15;
    let STime = Date.now() - days * 86400 * 1000;
    let daily = this.model.mongo("daily", this.sid, this.uid)
    return daily.mget(STime)
}

/**
 * @name active
 * @tip type=1-游戏公告,2-游戏充值,8-经典活动,9-超级邮件,88-超级活动,100-兑换码
 * 活动数据 
 */
exports.active = function () {
    let active = this.model.mongo("active", this.sid, this.uid)
    return active.mget();
}

/**
 * @name record
 * 成就数据
 */
exports.record = function () {
    let record = this.model.mongo("record", this.sid, this.uid)
    let _v = record.mget("val");
    return _v;
}


/**
 * @name collect
 * @param int bag 图鉴ID，留空获取所有
 * 图鉴数据
 */
exports.collect = function () {
    let bag = this.get("bag", "int");
    let collect = this.model.mongo("collect", this.sid, this.uid)
    let _v = collect.mget(bag);
    return _v;
}



/**
 * @name otherCollect
 * @param int bag 图鉴ID，留空获取所有
 * @param string uid  图鉴ID，留空获取所有
 * 获取他人的图鉴数据
 */
exports.otherCollect = function () {
    let bag = this.get("bag", "int");
    let uid = this.get("uid", "string");
    let collect = this.model.mongo("collect", this.sid, uid);
    let _v = collect.mget(bag);
    return _v;
}
